//
//  EPConst.swift
//  EPMM
//
//  Created by liujianlong on 2022/7/27.
//

import Foundation
import UIKit
import TCCKit

public let k_s_w = kUIScreenWidth / 375.0
public let k_s_h = kUIScreenHeight / 667.0
func k_w(_ value:CGFloat)->CGFloat{ return value * k_s_w}
func k_h(_ value:CGFloat)->CGFloat{ return value * k_s_h}


//MARK: - 根据屏幕宽度计算cell的宽度
/// 根据屏幕宽度计算cell的宽度
/// - Parameters:
///   - flow: UICollectionViewFlowLayout
///   - numForRow: 每行的个数 = 4
/// - Returns: cell的宽度
func itemWidth(_ flow:UICollectionViewFlowLayout, _ numForRow:Int = 4 ,_ screenWidth:CGFloat=kUIScreenWidth)->CGFloat{
    if numForRow <= 0 {return 0}
    let space = flow.scrollDirection == .horizontal ? flow.minimumLineSpacing : flow.minimumInteritemSpacing
    var w = screenWidth - flow.sectionInset.left - flow.sectionInset.right
    w = w - space * (CGFloat(numForRow) - 1.0)
    w = floor((w / CGFloat(numForRow)))
    return w
}

//MARK: - 根据布局计算UICollectionView的高度

/// 根据布局计算UICollectionView的高度
/// - Parameters:
///   - flow: UICollectionViewFlowLayout
///   - array: 数据源
///   - numForRow: 每行的个数 = 4
/// - Returns: UICollectionView的高度
func collectionH(_ flow:UICollectionViewFlowLayout, _ array:[Any], _ numForRow:Int = 4)->CGFloat{
    if numForRow <= 0{return 0}
    let row = ceil(Double(array.count) / CGFloat(numForRow))
    let space = flow.scrollDirection == .horizontal ? flow.minimumInteritemSpacing : flow.minimumLineSpacing
    let h = flow.itemSize.height * row + space * (row - 1.0) + flow.sectionInset.top + flow.sectionInset.bottom + flow.headerReferenceSize.height + flow.footerReferenceSize.height
    return ceil(h)
}

//navigationBarHeight默认高度44 （iPhoneX 88）
//tabBarHeight默认高度49     （iPhoneX 83）

//适配 350 375 414       568 667 736
func kAutoLayoutWidth(_ width: CGFloat) -> CGFloat {
    return width*kUIScreenWidth / 375
}
func kAutoLayoutHeigth(_ height: CGFloat) -> CGFloat {
    return height*kUIScreenHeight / 667
}
let BLEDIS = "蓝牙出问题了，快去检查一下吧～"
let LocalCustomArrayKey = "LocalCustomArrayKey"

//MARK: - 获取颜色/字体
///大背景色
let HEX_WHITE = "#FFFFFF"
/// 分割线
let HEX_LINE = "#EEEEEE"
///灰色 文字
let HEX_GRAY1 = "#CFCFCF"
/// 深灰色 文字
let HEX_GRAY2 = "#9B9B9B"
///黑色  主要文字标题/文字按钮
let HEX_BLACK = "#000000"
/// 橙色 消息提示/数据提示
let HEX_ORANGE = "#fb5620"
/// 黄色 消息提示/数据状态
let HEX_YELLOW = "#FFD300"
///绿色
let HEX_GREEN = "#00E0D3"
///带点灰色蒙罩的绿色
let HEX_GREEN2 = "#00C2B7"
///青色
let HEX_BLUE = "#005BBA"
/// 墨青色
let HEX_BLUE2 = "#092D74"
///主题红色
let HEX_RED = "#C5283B"
///背景颜色
let HEX_BG = "#C0C0C0"
///disenable状态下的背景颜色
let HEX_BG_DISABLE = "#C0C0C0"
///disenable状态下的边框颜色
let HEX_BORDER_DISABLE = "#727272"
///disenable状态下的文本颜色
let HEX_TEXT_DISABLE = "#727272"
///粗字体
let FONT_B = "Oswald-Bold"
///细字体
let FONT_L = "Oswald-Light"
///常规字体
let FONT_R = "Oswald-Regular"
/// 日期/导航栏/标题
let FONT_TITLE = font(FONT_R, 16)
/// 正文
let FONT_TEXT = font(FONT_R, 14)
/// 设备提示/电量信息
let FONT_TIP = font(FONT_R, 12)
class EPConst: NSObject
{
    @objc static let KMScale = 0.6213
    @objc static let AppID_Bugly = "2f4a197df5"
    @objc static let mapKey = "583574adfe64de9673a33e24b904a119"
    @objc class func hexColor(_ hex : String) -> UIColor {return hex.color()}
}
